import io.netty.channel.ChannelHandlerContext;

import java.util.concurrent.atomic.AtomicInteger;

public class ResponseMessageResolver extends Resolver {

    private static final AtomicInteger counter = new AtomicInteger(1);

    @Override
    boolean support(IMessage iMessage) {
        return iMessage.getType() == MessageTypeEnum.RESPONSE;
    }

    @Override
    IMessage resolver(IMessage iMessage, ChannelHandlerContext ctx) {
        int index = counter.getAndIncrement();
        System.out.println("[]" + index + ". receive response:" + iMessage.getBody());
        IMessage empty = new IMessage();
        empty.setType(MessageTypeEnum.EMPTY);
        return empty;
    }
}
